package hu.szyrt.bug.overlays;

import android.graphics.drawable.Drawable;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;

public class PlaceOverlayItem extends OverlayItem {

	private int id;
	private Drawable icon;
	
	
	public PlaceOverlayItem(int id, GeoPoint geopoint, String title, String snippet) {
		super(geopoint, title, snippet);
		this.id = id;		
	}
	
	
	// Setters --------------------------------------------
	public void setMarkerBounded(Drawable marker){
		boundCenter(marker);
		super.setMarker(marker);
	}
	
	public void setIcon(Drawable icon) {
		this.icon = icon;
	}
	
	// Getters --------------------------------------------
	public int getId() {
		return id;
	}
	
	public Drawable getIcon() {
		return icon;
	}
	
	
	// Public methods -------------------------------------
	public static Drawable boundCenterBottom(Drawable drawable){
		drawable.setBounds(
				-1 * drawable.getIntrinsicWidth() >> 1, 
				-1 * drawable.getIntrinsicHeight(), 
				drawable.getIntrinsicWidth() >> 1, 
				0);
		return drawable;
	}
	
	public static Drawable boundCenter(Drawable drawable){
		drawable.setBounds(
				-1 * drawable.getIntrinsicWidth() >> 1, 
				-1 * drawable.getIntrinsicHeight() >> 1, 
				drawable.getIntrinsicWidth() >> 1, 
				drawable.getIntrinsicHeight() >> 1);
		return drawable;
	}

}
